package edu.stu.cs.software.family.warehouse.domain;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import edu.stu.cs.software.family.base.domain.BaseTreeEntity;

@Entity
@Table(name = "O_WAREHOUSE_CATEGORY")
@NamedQueries({ @NamedQuery(name = "Category.getRoot", query = "select m from Category m where m.parent is null") })
public class Category extends BaseTreeEntity<Category, Long> {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1929417658559091164L;

	@Column
	String code;
	
	@Column
	String name;
	@Column(name = "SUM")
	int sum;
	@OneToMany(mappedBy = "Category", cascade = CascadeType.REMOVE, fetch = FetchType.EAGER)
	List<Product> products;

	public int getSum() {
		return sum;
	}

	public void setSum(int sum) {
		this.sum = sum;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	
}
